package com.byx.chatserver.entity;

import com.alibaba.fastjson.annotation.JSONType;
import com.byx.chatserver.util.FastJsonEnumSerializer;
import com.byx.springboot.unifiedresponseresult.entity.OnResultConverter;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;

/**
 * ResultCode
 *
 * @author Superb
 * @date 2020/10/30 11:14
 */
public enum ResultCode implements OnResultConverter {
    /* 状态码定义 */
    
    SUCCESS(200,"成功"),
    //用于出现异常时返回
    FAILED(400,"失败"),

    NOT_FOUND(404,"接口不存在"),
    INTERNAL_SERVER_ERROR(500,"服务器内部错误"),

    UNDEFINED(0,"未定义返回码"),

    /* 411-499 参数错误 */
    PARAM_IS_INVALID(411,"参数无效"),
    PARAM_IS_BLANK(412,"参数为空"),
    PARAM_TYPE_BIND_ERROR(413,"参数类型错误"),
    PARAM_NOT_COMPLETE(414,"参数缺失"),

    /* 501-599 用户错误 */
    USER_NOT_LOGGED_IN(501,"用户未登录，请登录"),
    USER_LOGIN_ERROR(502,"账户不存在或密码错误"),
    USER_ACCOUNT_FORBIDDEN(503,"账号已被禁用"),
    USER_NOT_EXIST(504,"用户不存在"),
    USER_HAS_EXISTED(505,"用户已存在"),

    VERIFICATION_CODE_SEND_FAILED(601,"验证码发送失败"),

    ;

    private final Integer code;
    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "ResultCode{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }

    @Override
    public com.byx.springboot.unifiedresponseresult.entity.ResultCode convert() {
        return new com.byx.springboot.unifiedresponseresult.entity.ResultCode(this.code,this.message);
    }
}
